// 函数类型
function foo(x: string, y: number): string {
    return x + y
}
foo("你好", 520)
console.log(foo("123", 678));


let fun = function (x: string, y: number): string {
    return x + y
}
console.log(fun("55", 88));

// 在ts中的完整写法
//在函数中规定数据类型，主要规定的是形参的数据类型和返回值的数据类型
let boo: (x: string, y: number) => string = function (x: string, y: number): string {
    return x + y
}
console.log(boo("234",565));

// 函数的参数问题
// 参数可有可无：
function boo1(x:string,y:string,z?:string):string {
    return x+y +z
}
console.log(boo1("12","34"));
console.log(boo1("12","34","67"));

// 有默认值
function boo2(x:string,y:string = "liuchaochao"):string{
    console.log(y);
    return x+y
    
}
console.log(boo2("123"));

// 有很多参数时
function boo3(x:string,y:string,...args:string[]):string{
    console.log(args);
    return x+y
}
console.log(boo3("123","456"));
console.log(boo3("qw","er","ty","ui"));


// 函数中的数据类型是如何使用接口来规定
// 函数调用签名
interface Fun {
    (x:string,y:string):string
}

let liuchao:Fun = function(x:string,y:string):string{
    return x+y
}
console.log(liuchao("abcd","efg"));
 











export {
    foo
}
